  function [v,s]=seeiw(MU,SD,g1,g2,t); 
% function [v,s]=seeiw(MU,SD,g1,g2,t); 
% 
% Function computes the (v,s) location parameters 
% of an Inverse-Wishart (Inverted-Gamma2) distribution 
% with mean MU and standard deviation SD 
% Also Plots the pdf of the IW(v,s), provides mode 
% as well as (approximate) percentiles by simulating data 
% Allows user to define the plot range and accuracy via (optional) inputs 
% g1,g2 and t 
% 
% Notation: if x ~ IW(v,s) then 
%           1/x ~  G(v/2,2/s) 
% i.e. v is the degrees of freedom 
%      s is the scale parameter 
% 
% Input
% -----
% MU    Mean > 0 
% SD    > 0 or inf for infinite 
% g1    Optional. Controls plot range. See iwplot.m for documentation 
% g2    Optional. Controls plot range. See iwplot.m for documentation 
% t     Optional. Controls accuracy of simulated percentiles.
%                 See iwplot.m for documentation 
% 
% Output 
% ------
% v     degrees of freedom 
% s     scale parameter 
% 
% Notes 1) if SD=inf then the degrees of freedom (v) are
%          set to 3 (mean exists) 
%       2) Uses functions iwplot.m & inwish_pdf.m 
%       3) iwplot.m is written so that it can be used independently 
%       i.e. to see how the density adjusts by changing v and/or s
%
% Alejandro Justiniano 3/17/04
if MU < 1e-7; error('Mean must be positive'); end;  
if SD < 1e-10; error('SD must be positive'); end; 

if SD==inf 
    v=3; 
else 
    v=2*(MU^2)/(SD^2) + 4;
end 
if nargin < 5 
    t=[]; 
    if nargin < 3; 
        g1=[]; g2=[];  
    end 
end 
s=MU*(v-2);
iwplot(v,s,g1,g2,t); 
fprintf('%-30s\n','Graph Plotted'); 
format short; 